package com.itfenghuang.day01.day02;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class A02_LoginServlet extends HttpServlet {
    /**
     *Servlet
     *      1). 接收请求
     *      2). 处理数据
     *      3). 响应用户
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //httpServletRequest 请求对象
        //httpServletResponse响应对象
        //获取请求参数  public String getparameter
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        System.out.println(username+password);
        //响应浏览器
        ServletOutputStream os = resp.getOutputStream();
        os.write(("Welcome you"+username).getBytes());
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
